package com.spring.quickstart.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.spring.quickstart.common.validator.groups.Add;
import com.spring.quickstart.common.validator.utils.ValidateUtils;
import com.spring.quickstart.entity.User;
import com.spring.quickstart.service.IDemoService;

@Service
public class DemoServiceImpl implements IDemoService {

	@Override
	public Map<String, Object> addUser(User user) {
		Map<String, Object> retMap = new HashMap<>();

		String validMsg = ValidateUtils.validateModel(user, Add.class);
		if (StringUtils.isNotEmpty(validMsg)) {
			retMap.put("errNo", 0);//验证失败
			retMap.put("errMsg", "参数校验失败！" + validMsg);
		}

		return retMap;
	}

}
